﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AnyOffice.Components;
using AnyOffice.DAL;
using AnyOffice.Model;

namespace AnyOffice.general.system.url
{
    public partial class index : ModulePage
    {
        private void GetUrl()
        {
            DataTable table = new UrlDao().SelectAll(base.Conn, "");
            if (table.Rows.Count > 0)
            {
                this.rptUrl.DataSource = table;
                this.rptUrl.DataBind();
            }
            else
            {
                this.litMessage.Text = base.ShowMessage("尚未添加网址");
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.Page.IsPostBack)
            {
                this.GetUrl();
            }
            if (this.Page.IsPostBack)
            {
                UrlDao dao = new UrlDao();
                UrlData data = new UrlData();
                data.UrlNo = Convert.ToInt32(this.txtUrlNo.Text);
                data.UrlDesc = this.txtUrlDesc.Text;
                data.Url = this.txtUrl.Text;
                dao.Insert(base.Conn, data);
                this.GetUrl();
                this.txtUrlNo.Text = "";
                this.txtUrlDesc.Text = "";
                this.txtUrl.Text = "";
            }
        }     

    }
}
